﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Negocio;
using Negocio.Interface;

namespace Interface
{
    public partial class TECadastroTributacao : Telerik.WinControls.UI.RadForm, ITCadastroTributacao
    {
        private NGTributacao controlador;

        public int triCodigo
        {
            set
            {
                if ((value.ToString()) == (int.MinValue.ToString()))
                {
                    txbCodigo.Text = string.Empty;
                    txbCodigo.Focus();
                }
                else
                    txbCodigo.Text = value.ToString();
            }
            get
            {
                if (txbCodigo.Text == string.Empty)
                    return int.MinValue;
                else
                    return int.Parse(txbCodigo.Text);
            }
        }

        public string triDescricao
        {
            set { txbDescricao.Text = value; }
            get { return txbDescricao.Text; }
        }

        public decimal triAliquota
        {
            set
            {
                if ((value.ToString()) == (decimal.MinValue.ToString()))
                {
                    txbAliquota.Text = string.Empty;
                }
                else
                    txbAliquota.Text = value.ToString();
            }
            get
            {
                if (txbAliquota.Text == string.Empty)
                    return decimal.MinValue;
                else
                    return decimal.Parse(txbAliquota.Text);
            }
        }

        public decimal triReducao
        {
            set
            {
                if ((value.ToString()) == (decimal.MinValue.ToString()))
                {
                    txbReducao.Text = string.Empty;
                }
                else
                    txbReducao.Text = value.ToString();
            }
            get
            {
                if (txbReducao.Text == string.Empty)
                    return decimal.MinValue;
                else
                    return decimal.Parse(txbReducao.Text);
            }
        }

        public string mensagem
        {
            set { Telerik.WinControls.RadMessageBox.Show(value,"  CotFácil  ", MessageBoxButtons.OK, RadMessageIcon.Error, MessageBoxDefaultButton.Button1);}
            get { return string.Empty; }
        }
        
        public TECadastroTributacao()
        {
            controlador = new NGTributacao(this);
            InitializeComponent();
        }

        private void btnFechar_Click_1(object sender, EventArgs e)
        {
            Close();
        }

        private void btnNovo_Click(object sender, EventArgs e)
        {
            controlador.limpaTela();
        }

        private void TECadastroTributacoes_Load(object sender, EventArgs e)
        {

        }

        private void btnGravar_Click(object sender, EventArgs e)
        {
            controlador.gravar();
        }

        private void txbCodigo_Validated(object sender, EventArgs e)
        {
            controlador.consultar(triCodigo);
        }

        private void btnExcluir_Click(object sender, EventArgs e)
        {
            controlador.deletar(triCodigo);
        }

    }
}
